#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;
const int N = 2e5 + 10;
char s[N];

int main()
{
	int t; scanf("%d", &t);
	while (t--)
	{
		int n; scanf("%d", &n);
		map<int, int> t;
		scanf("%s", s);
		int i = 0;
		bool jug = true;
		while (i < n)
		{
			if (s[i] == '0')
			{
				//cout << "i = " << i << " : ";
				if (i == 0 || i == n - 1) ++i;
				else if (s[i - 1] == '0') ++i;
				else if (s[i + 1] == '0') ++i;
				else if (i - 2 >= 0 && s[i - 2] == '0' && (t[i - 2] != -1 || (i - 4 >= 0 && t[i - 4] != 1)))
				{
					t[i] = -1;
					++i;
				}
				else if (i + 2 < n && t[i] != -1 && s[i + 2] == '0')
				{
					t[i] = 1;
					t[i + 2] = -1;
					++i;
				}
				else
				{
					jug = false;
					break;
				}
				//cout << " t[i] = " << t[i] << endl;
			}
			else ++i;
		}
		if(jug) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}
